package entity

import (
	"time"

	"shqsoft.cn/pasnj/base"
)

//TIndiClie 用户
type IndiWorkflow struct {
	ID          int          `gorm:"column:ID"`
	IDNO        string       `gorm:"column:IDNO"`
	NAME        string       `gorm:"column:CUNM"`
	EMID1       int          `gorm:"column:EMID1"`
	DSVL1       float64      `gorm:"column:DSVL1"`
	User1       User         `gorm:"ForeignKey:EMID1"`
	EMID2       *int         `gorm:"column:EMID2"`
	DSVL2       *float64     `gorm:"column:DSVL2"`
	User2       User         `gorm:"ForeignKey:EMID2"`
	EMID3       *int         `gorm:"column:EMID3"`
	DSVL3       *float64     `gorm:"column:DSVL3"`
	User3       User         `gorm:"ForeignKey:EMID3"`
	EMID4       *int         `gorm:"column:EMID4"`
	DSVL4       *float64     `gorm:"column:DSVL4"`
	User4       User         `gorm:"ForeignKey:EMID4"`
	EMID5       *int         `gorm:"column:EMID5"`
	DSVL5       *float64     `gorm:"column:DSVL5"`
	User5       User         `gorm:"ForeignKey:EMID5"`
	DSDT        *time.Time   `gorm:"column:DSDT"`
	STEP        int          `gorm:"column:STEP"`
	STEPCaption string       `gorm:"-"`
	SQR         int          `gorm:"column:SQR"`
	UTID        int          `gorm:"column:UTID"`
	Organ       Organization `gorm:"ForeignKey:UTID"`
	EMID        int          `gorm:"column:EMID"`
	STATE       int          `gorm:"column:STATE"`
	ANSTEP      int          `gorm:"column:ANSTEP"`
}

//TableName User用户表名
func (IndiWorkflow) TableName() string {
	return "V_INDI_DIVI_WORKFLOW"
}
func (u *IndiWorkflow) AfterFind() (err error) {
	if u.STEP == -1 {
		u.STEPCaption = "不同意"
	} else if u.STEP == 0 {
		u.STEPCaption = "填写申请"
	} else if u.STEP == 1 {
		u.STEPCaption = "复核确认"
	} else {
		u.STEPCaption = "完成"
	}
	return
}

func IndiWorkflowEF() base.EntityFunc {
	return func() interface{} {
		entity := IndiWorkflow{}
		return &entity
	}
}
func IndiWorkflowESF() base.EntitiesFunc {
	return func() interface{} {
		var entities []IndiWorkflow
		return &entities
	}
}

func init() {
	relationship := []string{"User1", "User2", "User3", "User4", "User5", "Organ"}
	base.DaoPoolObj.Put("IndiWorkflow", base.NewDefaultDao(IndiWorkflowEF(), IndiWorkflowESF(), relationship))
}
